package com.carsystems.service;

import com.carsystems.mapper.AdminUserMapper;
import com.carsystems.pojo.AdminUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

@Service
@Transactional
public class AdminServiceImpl implements AdminService{

    @Autowired
    private AdminUserMapper adminMapper;

    @Override
    public AdminUser login(AdminUser adminUser) {
        AdminUser adminDB = adminMapper.findAdmin(adminUser.getAd_number());
        if (!ObjectUtils.isEmpty(adminDB)){
           if (adminDB.getAd_password().equals(adminUser.getAd_password())){
               return adminDB;
           }else {
               throw new RuntimeException("密码不正确");
           }
        }else {
            throw new RuntimeException("用户名不正确");
        }
    }
}
